<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="/html/axios.min.js"></script>
    <script>
        function $(id) {
         return document.getElementById(id)
        }
        window.onload = function () {
            fullTables()
            axios.get("/user/getUserSession").then(resp =>{
                if(resp.data == ""){
                    $("indexSpan").innerHTML="你好，请重新登录"+"<a href='/html/login.html'>登陆</a>"
                }
                else {
                    $("img").src ="/html/img/"+resp.data.img
                    $("userSpan").innerHTML = resp.data.name
                    $("emailSpan").innerHTML = resp.data.email
                }
            });
        }
        function fullTables() {
            axios.get("/channel/findAll").then(resp =>{
                var channelObj = resp.data
                var str = ""
                channelObj.forEach(e =>{
                    str +=`<tr><td>${e.name}</td><td>${e.info}</td><td>${e.mainNumber}</td><td><a href="main.html?id=${e.id}&name=${e.name}">查看</a></td></tr>`
                });
                $("bodyDate").innerHTML = str
            })
        }
    </script>
</head>
<body>
    <span id="indexSpan"></span><br>
    <div id="userInfo">
        头像:<img id="img" style="width: 50px;height:50px"><br>
        用户名:<span id="userSpan"></span><br>
        用户邮箱:<span id="emailSpan"></span>
    </div>
    <table border="1" width="60%" cellspacing="0">
        <thead>
         <tr><th>频道名称</th><th>频道描述</th><th>主贴数量</th><th>操作</th></tr>
        </thead>
        <tbody id="bodyDate">

        </tbody>
    </table>
</body>
</html>